package com.neu.servlet.ww;

import com.alibaba.fastjson.JSONObject;
import com.neu.service.ww.OrderInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

@WebServlet(name = "MonthSaleServlet" ,urlPatterns = "/MonthSaleServlet.do")
public class MonthSaleServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setCharacterEncoding("utf-8");
        String key=request.getParameter("k_name");
        String month=request.getParameter("month");
        OrderInfoService orderInfoService=new OrderInfoService();
        List<Map<String,Object>> orderList=orderInfoService.doFindOrderInfoByMonth(month,key);
        HttpSession session = request.getSession();
        session.setAttribute("orderList",orderList);
        String json=JSONObject.toJSONString(orderList);
        PrintWriter pw=response.getWriter();
        pw.write(json);
        pw.close();
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
